class Solution:
    def permute(self, nums: List[int]) -> List[List[int]]:
        n = len(nums)
        res, path = [], []
        def dfs(i):
            if i == n:
                res.append(path.copy())
                return
            else:
                for j in nums:
                    if j not in path:
                        path.append(j)
                        dfs(i+1)
                        path.pop()
            return
        dfs(0)
        return res

if __name__ == "__main__":
    s = Solution()
    print(s.permute([1,2,3]))
    print(s.permute([0, 1]))
    print(s.permute([1]))
    